// 模态框系统类型定义

import type { Component } from 'vue'

export interface HeaderAction {
  id: string
  icon: Component
  type?: 'primary' | 'secondary' | 'danger'
  tooltip?: string
  handler?: (modal: Modal, action: HeaderAction) => void
}

export interface ModalAction {
  id: string
  label: string
  type?: 'primary' | 'secondary' | 'danger' | 'success'
  icon?: Component
  disabled?: boolean
  loading?: boolean
  autoClose?: boolean
  handler?: (modal: Modal, action: ModalAction) => void | Promise<void>
}

export interface Modal {
  id: string
  title: string
  icon?: Component
  size?: 'small' | 'medium' | 'large' | 'extra-large'
  fullscreen?: boolean
  closable?: boolean
  closeOnBackdrop?: boolean
  blur?: boolean
  showHeader?: boolean
  resizable?: boolean
  
  // 内容
  component?: Component
  props?: Record<string, any>
  content?: string
  message?: string
  
  // 操作
  actions?: ModalAction[]
  headerActions?: HeaderAction[]
  
  // 样式
  style?: Record<string, string>
  
  // 元数据
  createdAt: number
}

export interface ModalOptions {
  title: string
  icon?: Component
  size?: Modal['size']
  fullscreen?: boolean
  closable?: boolean
  closeOnBackdrop?: boolean
  blur?: boolean
  showHeader?: boolean
  resizable?: boolean
  
  // 内容
  component?: Component
  props?: Record<string, any>
  content?: string
  message?: string
  
  // 操作
  actions?: ModalAction[]
  headerActions?: HeaderAction[]
  
  // 样式
  style?: Record<string, string>
}

export interface ModalStore {
  modals: Modal[]
  openModal: (options: ModalOptions) => string
  closeModal: (id: string) => void
  updateModal: (id: string, updates: Partial<Modal>) => void
  clearModals: () => void
}